package com.cn.filter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置token拦截器
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminTokenFilter())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/admin/login/**",
                        "/admin/file/**",
                        "/admin/upload/**",
                        "/openbase/**",
                        "/error",
                        "/openid/**",
                        "/favicon.ico",
                        "/v2/api-docs",
                        "/swagger-resources",
                        "/webjars/**",
                        "/doc.html/**"
                );
    }

    @Bean
    public AdminTokenFilter adminTokenFilter() {
        return new AdminTokenFilter();
    }

}
